package com.stack.wemedia.controller.v1;

import com.stack.model.common.dtos.ResponseResult;
import com.stack.model.wemedia.dtos.WmNewsDto;
import com.stack.model.wemedia.dtos.WmNewsPageReqDto;
import com.stack.wemedia.service.WmNewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author llz
 * @date 2023/10/10 21:18
 * @description
 */
@Api("文章管理")
@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    @ApiOperation("获取文章列表")
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmNewsPageReqDto dto){
        return wmNewsService.findList(dto);
    }

    @ApiOperation("提交文章审核")
    @PostMapping("/submit")
    public ResponseResult submitNews(@RequestBody WmNewsDto dto){
        return wmNewsService.submitNews(dto);
    }

    @ApiOperation("文章上下架")
    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsDto dto){
        return wmNewsService.downOrUp(dto);
    }

    @ApiOperation("查看文章细节")
    @GetMapping("/one/{id}")
    public ResponseResult getArticleDetails(@PathVariable("id") Integer id){
        return wmNewsService.getArticleDetails(id);
    }

    @ApiOperation("删除文章")
    @GetMapping("/del_news/{id}")
    public ResponseResult deleteNews(@PathVariable("id") Integer id){
        return wmNewsService.deleteNews(id);
    }

}
